package com.wenbing.miio.mi.device.simulator;

import com.wenbing.miio.core.Bootable;
import com.wenbing.miio.util.TimeUtil;

import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;
import java.util.concurrent.TimeUnit;

/**
 * @author wen bing
 * @projectName: miio
 * @package: com.wenbing.miio.mi.device.simulator
 * @className: LocalClock
 * @date 2024/09/22 23:23
 **/
public class LocalClock extends Clock implements Bootable {

    private long start;

    @Override
    public ZoneId getZone() {
        return null;
    }

    @Override
    public Clock withZone(ZoneId zone) {
        return null;
    }

    @Override
    public Instant instant() {
        return Instant.ofEpochSecond(TimeUtil.now(TimeUnit.SECONDS) - this.start);
    }

    @Override
    public void boot() {
        this.start = TimeUtil.now(TimeUnit.SECONDS);
    }
}
